
#ifndef __LIBERTY_ENGINE_XML_INODE_H__
#define __LIBERTY_ENGINE_XML_INODE_H__

#include <Liberty3D/Liberty3D.h>

#include <string>
#include <vector>

namespace Liberty { namespace Engine { namespace Xml {

    class INode {
    public:
        enum Type {
            DOC,
            ELEMENT,
            TEXT,
            CDATA,
            UNKNOWN
        };

    public:
        virtual ~INode() {}

    public:
        virtual Type        type() const = 0;
        virtual std::string data() const = 0;

    public:
        virtual bool        hasAttribute(const std::string& name) const = 0;
        virtual std::string attribute   (const std::string& name, const std::string& defaultValue = std::string()) const = 0;
        virtual void        setAttribute(const std::string& name, const std::string& v) = 0;

    public:
        virtual void childs(std::vector< std::shared_ptr<INode> >&) const = 0;
        virtual std::shared_ptr<INode> firstChild() const = 0;
        virtual std::shared_ptr<INode> firstChildElement(const std::string&) const = 0;
        virtual std::shared_ptr<INode> nextSiblingElement(const std::string&) const = 0;

    public:
        virtual std::shared_ptr<INode> addElement(const std::string& name, const std::shared_ptr<INode>& before = std::shared_ptr<INode>()) = 0;
        virtual std::shared_ptr<INode> addText   (const std::string& data, const std::shared_ptr<INode>& before = std::shared_ptr<INode>()) = 0;

        virtual void removeChild(const std::shared_ptr<INode>& child) = 0;
        
    public:
        virtual std::string toString() const = 0;
        virtual void toXml(const std::string& fileName) const = 0;
        virtual void toXml(std::ios&) const = 0;
        virtual void toXml(std::streambuf* buf) const = 0;
    };

}}}

#endif
